package com.snnsh.kjb.lottery.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.snnsh.kjb.lottery.po.LotteryRecordPO;
import com.snnsh.kjb.lottery.service.LotteryRecordService;
import com.snnsh.kjb.lottery.vo.ProductVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

/**
 * packageName com.snnsh.kjb.lottery.web.controller
 *
 * @author wick
 * @version V1.0.0
 * @date 2025/5/27
 */
@RestController
@RequestMapping("/lotteryRecord")
public class LotteryRecordController extends BaseController{

    @Autowired
    private LotteryRecordService lotteryRecordService;

    @RequestMapping("/list")
    public JSONObject list(String prodName) {
        List<LotteryRecordPO> list = lotteryRecordService.list(prodName);
        return success(list);
    }
    /**
     * @description 抽奖
     * @param : 
     * @return JSONObject
     * @author wick
     * @date 2025/5/28
     */
    @RequestMapping("/lottery")
    public JSONObject lottery() {
        try {
            ProductVO productVO = lotteryRecordService.lotteryProduct();
            return successData(productVO);
        }
        catch (Exception e) {
            return errorMsg(e.getMessage());
        }
    }
    /**
     * @description 清空抽奖记录
     * @param :
     * @return JSONObject
     * @author wick
     * @date 2025/5/28
     */
    @RequestMapping("/clearRecord")
    public JSONObject clearRecord(){
        lotteryRecordService.clearRecord();
        return success("清空成功");
    }
}
